10 DIM W1(7),W2(7),W0$(7),WF(6),DF(7)
20 GOSUB 1010:KEY OFF
30 RANDOMIZE TIMER
40 REM set prices and max sales
50 COLOR 14,0:CLS:D=1000:PL=75 :PS=106:PC=98:MAX=100
60 F=14:B=0:S=0:L=0:C=0:S1=0:L1=0:C1=0
70 W$="Sunny        Partly CloudyCloudy       Rainy        cloudy       Partly Cloudy"
80 GOSUB 1200
90 COLOR 3,0:GOSUB 820:GOSUB 900
100 REM do weeks
110 FOR WK=1 TO 10
120 TEMP=60+5*INT(10*RND)
130 COLOR 2,0:LOCATE 3,70:PRINT WK
140 WTHR=1+13*INT(6*RND):LOCATE ,45:PRINT MID$(W$,WTHR,13);
150 LOCATE ,60:PRINT TEMP;CHR$(248);"  "
160 COLOR F,B:LOCATE 13,42:PRINT"Purchases:";
170 GOSUB 740:GOSUB 580:GOSUB 630:GOSUB 680
180 GOSUB 740:LOCATE 19,1:PRINT"Do you want to make any changes (enter number)?"
190 LOCATE ,10:PRINT"0 - no changes"
200 LOCATE ,10:PRINT"1 - change sugar"
210 LOCATE ,10:PRINT"2 - change lemonade"
220 LOCATE ,10:PRINT"3 - change cups"
230 LOCATE ,8:INPUT;I
240 LOCATE 19,1:PRINT SPACE$(75):PRINT SPACE$(75):PRINT SPACE$(75)
250 PRINT SPACE$(75):PRINT SPACE$(75):PRINT SPACE$(75);
260 IF I=0 THEN 320
270 ON I GOTO 290,300,310
280 BEEP:GOTO 180
290 D=D+PS*S1:GOSUB 940:GOSUB 580:GOTO 180
300 D=D+PL*L1:GOSUB 940:GOSUB 630:GOTO 180
310 D=D+PC*C1:GOSUB 940:GOSUB 680:GOTO 180
320 GOSUB 780:GOSUB 900:IF AMT<>0 THEN 340
330 COLOR 4,0:BEEP:LOCATE 24,1:PRINT"You have no supplies!!!";:GOTO 160
340 GOSUB 740:INPUT"How much will you charge for lemonade (1 - 99) ",PR
350 IF PR>0 AND PR<100 THEN 370
360 COLOR 4,0:BEEP:PRINT"enter a number between 1 and 99!!!";:COLOR F,B:GOTO 340
370 GOSUB 990:COLOR 0,7:LOCATE 14,10:PRINT"           ";
380 LOCATE 14,11:PRINT PR;"cents";
390 REM do each day
400 FOR DAY=1 TO 7:GOSUB 1420:COLOR 0,0:GOSUB 740:COLOR 9,0:PRINT W0$(DAY)
410 COLOR 0,0:FOR J=13 TO 4 STEP -1:LOCATE J,33:PRINT B$;:NEXT J
420 COLOR 4,0:J=13:K=55
430 LOCATE J,33:PRINT B$;:J=J-1:K=K+5:IF K<W1(DAY) THEN 430
440 GOSUB 1510:GOSUB 1690
450 FOR I=1 TO SALES:COLOR 14,0
460 LOCATE 23,20:PRINT"Sales ==> ";I
470 D=D+PR:C=C-1:L=L-10:S=S-4:GOSUB 900
480 IF AMT<>0 THEN 510
490 I=SALES:DAY=7:LOCATE 24,1:COLOR 4,0
500 BEEP:PRINT"You ran out of supplies!!!";
510 NEXT I:NEXT DAY
520 NEXT WK
530 LOCATE 24,40:COLOR 4,0:PRINT"Do you want to play again (y/n)?";
540 A$=INKEY$:IF A$="" THEN 540
550 IF LEFT$(A$,1)="y" OR LEFT$(A$,1)="Y" THEN 50
560 IF LEFT$(A$,1)<>"n" AND LEFT$(A$,1)<>"N" THEN 540
570 GOSUB 1140:END
580 GOSUB 740:PRINT"How much sugar do you want ($ ";
590 PRINT USING "#.##";PS/100;:INPUT" / lb.) ",S1
600 IF D-S1*PS<0 THEN GOSUB 750:GOTO 580
610 LOCATE 14,45:PRINT "lbs. of sugar = ";S1;"  "
620 D=D-S1*PS:GOSUB 940:RETURN
630 GOSUB 740:PRINT"How much lemonade ($ ";
640 PRINT USING "#.##";PL/100;:INPUT" / quart) ",L1
650 IF D-L1*PL<0 THEN GOSUB 750:GOTO 630
660 LOCATE 15,45:PRINT"quarts of lemonade = ";L1;"  "
670 D=D-L1*PL:GOSUB 940:RETURN
680 GOSUB 740:PRINT"How many packages of 100 cups ($ ";
690 PRINT USING "#.##";PC/100;:INPUT" / package) ",C1
700 IF D-C1*PC<0 THEN GOSUB 750:GOTO 680
710 LOCATE 16,45:PRINT"packages of 100 cups = ";C1;"  "
720 D=D-C1*PC:GOSUB 940:RETURN
730 REM clear question line
740 LOCATE 23,1:PRINT SPACE$(75):LOCATE 23,1:RETURN
750 COLOR 4,0:BEEP:LOCATE 24,1:PRINT"You don't have that much!!!";
760 COLOR F,B:RETURN
770 REM add purchases to supplies
780 S=S+100*S1:L=L+100*L1:C=C+100*C1:S1=0:L1=0:C1=0
790 LOCATE 13,42:PRINT SPACE$(35):LOCATE ,42:PRINT SPACE$(35)
800 LOCATE ,42:PRINT SPACE$(35):LOCATE ,42:PRINT SPACE$(35):RETURN
810 REM print headings
820 LOCATE 1,42:PRINT"You have";
830 LOCATE 3,42:PRINT"Weather prediction for week";
840 LOCATE 6,42:PRINT"Supplies:"
850 LOCATE ,45:PRINT"lbs. of sugar "
860 LOCATE ,45:PRINT"quarts of lemonade "
870 LOCATE ,45:PRINT"number of cups "
880 RETURN
890 REM update values
900 COLOR 4,0
910 LOCATE 7,70:PRINT USING "##.##";S/100
920 LOCATE ,70:PRINT USING "##.##";L/100
930 LOCATE ,70:PRINT C;"  "
940 COLOR 4,0:LOCATE 1,70:PRINT "$";:PRINT USING "###.##";D/100
950 COLOR 2,0:X1=INT((S+S1*100)/4):X2=INT((L+L1*100)/10):X3=C+(C1*100)
960 AMT=X1:IF X2<X1 THEN AMT=X2
970 IF X3<AMT THEN AMT=X3
980 LOCATE 11,42:PRINT"You can make";AMT;"cups of lemonade   ";
990 LOCATE 24,1:PRINT SPACE$(75);
1000 COLOR F,B:RETURN
1010 REM switch output to the color monitor
1020 KEY OFF:CLS:ENV=0:DEF SEG=&H40:IF PEEK(&H63)=212 THEN ENV=1:GOTO 1050
1030 LOCATE ,,0:DEF SEG=0
1040 POKE &H410,(PEEK(&H410) AND &HCF) OR &H10
1050 DEF SEG:SCREEN 1:SCREEN 0:WIDTH 40:WIDTH 80
1060 COLOR 7,0:LOCATE ,,1,6,7
1070 REM init. arrays
1080 W0$(1)="Sunday   ":W0$(2)="Monday   ":W0$(3)="Tuesday  "
1090 W0$(4)="Wednesday":W0$(5)="Thursday ":W0$(6)="Friday   "
1100 W0$(7)="Saturday ":WF(1)=1:WF(2)=.8:WF(3)=.6:WF(4)=.3:WF(5)=.6:WF(6)=.8
1110 DF(1)=.9:DF(2)=.5:DF(3)=.7:DF(4)=.6:DF(5)=.7:DF(6)=.8:DF(7)=1
1120 RETURN
1130 REM switch to monochrome
1140 KEY OFF:IF ENV=1 THEN COLOR 7,0:RETURN
1150 COLOR 0,0:CLS:LOCATE ,,0:DEF SEG=0
1160 POKE &H410,PEEK(&H410) OR &H30:DEF SEG
1170 SCREEN 1:SCREEN 0:WIDTH 40:WIDTH 80:COLOR 7,0:LOCATE ,,1,12,13
1180 RETURN
1190 REM draw lemonade stand
1200 LOCATE 1,1:COLOR 14,1:B$=CHR$(219):C$=B$+B$:D$=C$+C$:E$=D$+D$
1210 FOR I=1 TO 4:PRINT SPACE$(30):NEXT I
1220 PRINT"    "B$E$D$E$B$"    "
1230 PRINT"   "C$E$D$E$C$"   "
1240 PRINT"  "B$C$E$D$E$C$B$"  "
1250 COLOR 6,1
1260 FOR I=1 TO 4:PRINT"   "B$"                      "B$"   ":NEXT I
1270 COLOR 14,1
1280 FOR I=1 TO 4:PRINT"  "B$C$E$D$E$C$B$"  ":NEXT I
1290 COLOR ,2:PRINT SPACE$(30)
1300 COLOR 5,15:LOCATE 6,6:PRINT"ROG'S LEMONADE STAND";
1310 COLOR 0,7:LOCATE 13,10:PRINT" $ PRICE $ "
1320 LOCATE 14,10:PRINT"           "
1330 COLOR 7,0:T=105:LOCATE 2,32:PRINT "TEMP."
1340 LOCATE ,32:PRINT CHR$(222)B$CHR$(221)
1350 FOR I=1 TO 10:LOCATE ,32:PRINT CHR$(222)" "CHR$(221);T
1360 T=T-5:NEXT I:COLOR 7,4
1370 LOCATE ,32:PRINT B$" "B$
1380 LOCATE ,32:PRINT CHR$(221)" "CHR$(222)
1390 LOCATE ,32:PRINT B$CHR$(220)B$
1400 RETURN
1410 REM figure weather for week
1420 FOR K=1 TO 7:W1(K)=TEMP-10+5*INT(5*RND)
1430 IF W1(K)<65 THEN W1(K)=65 ELSE IF W1(K)>105 THEN W1(K)=105
1440 NEXT K:WTHR=1+INT(WTHR/13):FOR K=1 TO 7:W2(K)=WTHR:Z=1+INT(10*RND)
1450 ON Z GOTO 1460,1470,1470,1490,1490,1490,1490,1470,1470,1460
1460 W2(K)=WTHR+2:GOTO 1480
1470 W2(K)=WTHR+1
1480 IF W2(K)>6 THEN W2(K)=W2(K)-6
1490 NEXT K:RETURN
1500 REM add weather
1510 F$=CHR$(219):WB=0:ON W2(DAY) GOTO 1520,1520,1530,1540,1530,1520
1520 WF=1:GOTO 1550
1530 WF=8:WB=1:F$=CHR$(177):GOTO 1550
1540 WF=8:WB=0:F$="/"
1550 COLOR WF,WB:FOR J=1 TO 4:LOCATE J,1:FOR K=1 TO 30:PRINT F$;:NEXT K,J
1560 LOCATE 5,1:PRINT F$F$F$F$;:LOCATE 5,27:PRINT F$F$F$F$;
1570 LOCATE 6,1:PRINT F$F$F$;:LOCATE 6,28:PRINT F$F$F$;
1580 LOCATE 7,1:PRINT F$F$;:LOCATE 7,29:PRINT F$F$;
1590 FOR J=8 TO 11:LOCATE J,1:PRINT F$F$F$;:LOCATE J,5:FOR K=1 TO 22:PRINT F$;
1600 NEXT K:LOCATE J,28:PRINT F$F$F$;:NEXT J
1610 FOR J=12 TO 15:LOCATE J,1:PRINT F$F$;:LOCATE J,29:PRINT F$F$;:NEXT J
1620 IF W2(DAY)=1 THEN RETURN
1630 F$=CHR$(219)+CHR$(219):WF=15:IF W2(DAY)>2 AND W2(DAY)<6 THEN WF=7
1640 FOR K=9 TO 20:LOCATE 1,K:IF RND>.7 THEN PRINT F$;
1650 NEXT K:FOR K=3 TO 27:LOCATE 2,K:IF RND>.3 THEN PRINT F$;
1660 NEXT K:FOR K=7 TO 22:LOCATE 3,K:IF RND>.6 THEN PRINT F$;
1670 NEXT K:RETURN
1680 REM find sales for day
1690 TF=((W1(DAY)-55)*2)/100
1700 PF=(100-PR)/100
1710 SALES=1+INT(MAX*TF*PF*WF(W2(DAY))*DF(DAY))
1720 RETURN